package com.zjitc.bookshop39.controller;

import com.zjitc.bookshop39.service.BookService;
import com.zjitc.bookshop39.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试用户控制器
 * 仅用于开发环境添加测试用户
 */
@RestController
public class DelBookCOntroller {
     @Autowired
     private BookService bookService;
    /**
     * 删除book
     */
    @PreAuthorize("hasAnyAuthority('sys:book:delete')")
    @DeleteMapping("admin/delete/{id}")
    public ApiResponse<Void> delBook(@PathVariable int id) {
        try {
            bookService.delBook(id);
            return ApiResponse.success("删除图书成功", null);
        } catch (Exception e) {
            return ApiResponse.error("删除图书失败：" + e.getMessage());
        }
    }


} 